package com.qms.qep.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.qms.common.core.controller.BaseController;
import com.qms.common.core.domain.AjaxResult;
import com.qms.common.core.page.TableDataInfo;
import com.qms.qep.domain.RepairEvaluation;
import com.qms.qep.service.IRepairEvaluationService;

/**
 * 维修评价Controller
 */
@RestController
@RequestMapping("/qep/repair-evaluation")
public class RepairEvaluationController extends BaseController {
    @Autowired
    private IRepairEvaluationService repairEvaluationService;

    /**
     * 查询维修评价列表
     */
    @PreAuthorize("@ss.hasPermi('qep:repair-evaluation:list')")
    @GetMapping("/list")
    public TableDataInfo list(RepairEvaluation repairEvaluation) {
        startPage();
        List<RepairEvaluation> list = repairEvaluationService.selectRepairEvaluationList(repairEvaluation);
        return getDataTable(list);
    }

    /**
     * 获取维修评价详细信息
     */
    @PreAuthorize("@ss.hasPermi('qep:repair-evaluation:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id) {
        return success(repairEvaluationService.selectRepairEvaluationById(id));
    }
    
    /**
     * 根据维修任务ID查询维修评价
     */
    @PreAuthorize("@ss.hasPermi('qep:repair-evaluation:query')")
    @GetMapping(value = "/task/{repairTaskId}")
    public AjaxResult getInfoByTaskId(@PathVariable("repairTaskId") Integer repairTaskId) {
        return success(repairEvaluationService.selectRepairEvaluationByTaskId(repairTaskId));
    }

    /**
     * 新增维修评价
     */
    @PreAuthorize("@ss.hasPermi('qep:repair-evaluation:add')")
    @PostMapping
    public AjaxResult add(@RequestBody RepairEvaluation repairEvaluation) {
        return toAjax(repairEvaluationService.insertRepairEvaluation(repairEvaluation));
    }

    /**
     * 修改维修评价
     */
    @PreAuthorize("@ss.hasPermi('qep:repair-evaluation:edit')")
    @PutMapping
    public AjaxResult edit(@RequestBody RepairEvaluation repairEvaluation) {
        return toAjax(repairEvaluationService.updateRepairEvaluation(repairEvaluation));
    }

    /**
     * 删除维修评价
     */
    @PreAuthorize("@ss.hasPermi('qep:repair-evaluation:remove')")
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids) {
        return toAjax(repairEvaluationService.deleteRepairEvaluationByIds(ids));
    }
} 